<!doctype html>
<html class="no-js" lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>类目管理</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- favicon
         ============================================ -->
    <link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico">
    <!-- Google Fonts
		============================================ -->
    <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,700,900" rel="stylesheet">
    <!-- Bootstrap CSS
		============================================ -->
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <!-- Bootstrap CSS
		============================================ -->
    <link rel="stylesheet" href="css/font-awesome.min.css">
    <!-- owl.carousel CSS
		============================================ -->
    <link rel="stylesheet" href="css/owl.carousel.css">
    <link rel="stylesheet" href="css/owl.theme.css">
    <link rel="stylesheet" href="css/owl.transitions.css">
    <!-- animate CSS
		============================================ -->
    <link rel="stylesheet" href="css/animate.css">
    <!-- normalize CSS
		============================================ -->
    <link rel="stylesheet" href="css/normalize.css">
    <!-- meanmenu icon CSS
		============================================ -->
    <link rel="stylesheet" href="css/meanmenu.min.css">
    <!-- main CSS
		============================================ -->
    <link rel="stylesheet" href="css/main.css">
    <!-- educate icon CSS
		============================================ -->
    <link rel="stylesheet" href="css/educate-custon-icon.css">
    <!-- morrisjs CSS
		============================================ -->
    <link rel="stylesheet" href="css/morrisjs/morris.css">
    <!-- mCustomScrollbar CSS
		============================================ -->
    <link rel="stylesheet" href="css/scrollbar/jquery.mCustomScrollbar.min.css">
    <!-- metisMenu CSS
		============================================ -->
    <link rel="stylesheet" href="css/metisMenu/metisMenu.min.css">
    <link rel="stylesheet" href="css/metisMenu/metisMenu-vertical.css">
    <!-- calendar CSS
		============================================ -->
    <link rel="stylesheet" href="css/calendar/fullcalendar.min.css">
    <link rel="stylesheet" href="css/calendar/fullcalendar.print.min.css">
    <!-- style CSS
		============================================ -->
    <link rel="stylesheet" href="style.css">
    <!-- responsive CSS
		============================================ -->
    <link rel="stylesheet" href="css/responsive.css">
    <!-- modernizr JS
		============================================ -->
    <script src="js/vendor/jquery-1.12.4.min.js"></script>
    <script src="js/vendor/modernizr-2.8.3.min.js"></script>
    <script src="js/vue.js"></script>

    <!--    bootstrap-table-->

    <script src="js/data-table/bootstrap-table.js"></script>
    <script src="js/data-table/bootstrap-table-zh-CN.js"></script>

    <!--    <link rel="stylesheet" href="https://unpkg.com/bootstrap-table@1.15.3/dist/bootstrap-table.min.css">-->
    <!--    <script src="https://unpkg.com/bootstrap-table@1.15.3/dist/bootstrap-table.min.js"></script>-->
    <!--    <script src="https://cdn.bootcss.com/bootstrap-table/1.11.1/locale/bootstrap-table-zh-CN.min.js"></script>-->

    <!--    <script src="https://how2j.cn/study/js/jquery/2.0.0/jquery.min.js"></script>-->
    <!--    <link href="https://how2j.cn/study/css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">-->
    <script>


        $(function () {
            toitemtable();
        })

        function toitemtable() {
            $('#itemtable').bootstrapTable({
                url: 'http://localhost:8080/item/getAllItem',
                method: 'GET',
                columns: [
                    {title: '类目名称', field: 'name', align: 'center'},
                    {title: '英文名称', field: 'alias', align: 'center'},
                    {title: '操作', field: 'id', align: 'center', formatter: operation}
                ],
                pagination: true,
                pageSize: 5,
                pageList: [5, 10, 15, 20],
                smartDisplay: false,
                sidePagination: 'client'
            });
        }


        function operation(value, row) {
            let name = row.name;
            let alias = row.alias;
            let id = value;
            let inner = "<button type=\"button\" class=\"btn btn-primary\" data-toggle=\"modal\"  onclick=\"delItem('" + id + "')\">\n" +
                " 删除" +
                "</button><br>" +
                // "<input id='id111' type='hidden' value='"+id+"'>" +
                "<button type=\"button\" class=\"btn btn-primary\" data-toggle=\"modal\" data-target=\"#myModal\" onclick='toid(" + id + ")'>\n" +
                " 修改" +
                "</button>";
            return inner;
        }

        function toid(id) {
            $("#iid").val(id)
        }

        function delItem(id) {
            $.ajax({
                url: 'http://localhost:8080/item/delItem',
                type: 'GET',
                dataType: 'json',
                data: {
                    id: id,
                    opr: "delItem"
                },
                success: function (data) {
                    if (data == 1) {
                        alert("类目下有商品，不能删除")
                    } else {
                        alert("删除成功");
                        $("#itemtable").bootstrapTable("destroy");
                        toitemtable();
                    }
                }
            });

        }


        $(function () {
            $("#updItemSubmit").click(function () {
                let itemName = $("#upditemName").val();
                let engName = $("#updengName").val();
                let itemId = $("#iid").val();
                if ((itemName == null || itemName.trim() == "") || (engName == null || engName.trim() == "")) {
                    alert("不能为空或全部是空格");
                } else {
                    $.ajax({
                        url: 'http://localhost:8080/item/updItem',
                        type: 'POST',
                        data: {
                            id: itemId,
                            name: itemName,
                            alias: engName
                        },
                        success: function (data) {
                            if (data == 1) {
                                alert("类目下有商品，不能修改");
                            } else {
                                alert("修改成功");
                                $("#itemtable").bootstrapTable("destroy");
                                toitemtable();
                            }
                        }

                    })
                }

            })

        })


    </script>

    <style>
        .table>tbody>tr>td{
            vertical-align:middle
        }

    </style>
</head>

<body>

<!--修改类目-->

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <input id="iid" type="hidden">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button data-dismiss="modal" class="close" type="button"><span aria-hidden="true">×</span><span
                        class="sr-only">Close</span></button>
                <h4 class="modal-title">修改</h4>
            </div>
            <div class="modal-body" align="center">


                <form class="form-inline" id="updItem">
                    <div style="overflow: hidden; margin: 0 auto">
                        <div class="form-group" style="padding-top:20px ">
                            <label class="sr-only" for="upditemName">类别名称</label>
                            <input type="text" class="form-control" id="upditemName" placeholder="类别名称" name="upditemName">
                        </div>
                        <div class="form-group" style="padding-top:20px ">
                            <label class="sr-only" for="updengName">英文名字</label>
                            <input type="text" class="form-control" id="updengName" placeholder="英文名字" name="updengName">
                        </div>
                        <div class="form-group" style="padding-top:20px ">
                            <button class="btn btn-default" id="updItemSubmit">修改</button>
                        </div>
                    </div>
                </form>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>


<!--[if lt IE 8]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade
    your browser</a> to improve your experience.</p>
<![endif]-->
<!-- Start Left menu area -->
<div class="left-sidebar-pro">
    <!--    <img src="http://localhost/">-->
    <nav id="sidebar" class="">
        <div class="sidebar-header">
            <a href="index.html"><img class="main-logo" src="img/logo/logo.png" alt=""/></a>
            <strong><a href="index.html"><img src="img/logo/logosn.png" alt=""/></a></strong>
        </div>
        <div class="left-custom-menu-adp-wrap comment-scrollbar">
            <nav class="sidebar-nav left-sidebar-menu-pro">
                <ul class="metismenu" id="menu1">
                    <li class="active">
                        <a class="has-arrow" href="index.html">
                            <span class="fa fa-id-card"></span>
                            <span class="mini-click-non">用户信息</span>
                        </a>
                        <ul class="submenu-angle" aria-expanded="true">
                            <li><a href="index.html"><span class="mini-sub-pro">用户列表</span></a></li>
                            <li><a href="goodsManager.html"><span class="mini-sub-pro">商品列表</span></a></li>
                            <li><a href="order.html"><span class="mini-sub-pro">订单管理</span></a></li>
                            <li><a href="classify.html"><span class="mini-sub-pro">类目管理</span></a></li>
                            <li><a href="sc.html"><span class="mini-sub-pro">客户服务</span></a></li>
                        </ul>
                    </li>
                    <li>
                        <a title="Landing Page" href="adminUser.html" aria-expanded="false"><span
                                class="fa fa-user-circle-o" aria-hidden="true"></span> <span
                                class="mini-click-non">系统用户</span></a>
                    </li>
                </ul>
            </nav>
        </div>
    </nav>
</div>
<!-- End Left menu area -->
<!-- Start Welcome area -->
<div class="all-content-wrapper">
    <div class="container-fluid">
        <div class="row">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div class="logo-pro">
                    <a href="index.html"><img class="main-logo" src="img/logo/logo.png" alt=""/></a>
                </div>
            </div>
        </div>
    </div>
    <div class="header-advance-area">
        <div class="header-top-area">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <div class="header-top-wraper">
                            <div class="row">
                                <div class="col-lg-1 col-md-0 col-sm-1 col-xs-12">
                                    <div class="menu-switcher-pro">
                                        <button type="button" id="sidebarCollapse"
                                                class="btn bar-button-pro header-drl-controller-btn btn-info navbar-btn">
                                            <i class="fa fa-bars"></i>
                                        </button>
                                    </div>
                                </div>

                                <div class="col-lg-5 col-md-5 col-sm-12 col-xs-12 col-lg-offset-6 col-md-offse-7 col-sm-offse-6 col-xs-offse-12">
                                    <div class="header-right-info">
                                        <ul class="nav navbar-nav mai-top-nav header-right-menu">
                                            <li class="nav-item">
                                                <a href="#" data-toggle="dropdown" role="button" aria-expanded="false"
                                                   class="nav-link dropdown-toggle">
                                                    <img id="headImgs" src="img/product/pro4.jpg" alt=""
                                                         style="width: 26px;height: 26px;border-radius: 100%"/>
                                                    <span class="admin-name" id="headName"></span>
                                                    <i class="fa fa-angle-down edu-icon edu-down-arrow"></i>
                                                </a>
                                                <ul role="menu"
                                                    class="dropdown-header-top author-log dropdown-menu animated zoomIn">

                                                    <li><a onclick="logOut()"><span
                                                            class="edu-icon edu-locked author-log-ic"
                                                            style="cursor:pointer"></span>登出</a>
                                                    </li>
                                                </ul>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>


        <div>

            <h1 align="center" style="position: relative; top: 98px">添加类目</h1>
            <div align="center" style="position: relative;padding-top: 6%">
                <!--            类目添加表-->
                <form class="form-inline" id="addItem">
                    <div class="form-group" style="padding-top:20px ">
                        <label class="sr-only" for="itemName">类别名称</label>
                        <input type="text" class="form-control" id="itemName" placeholder="类别名称" name="iterName">
                    </div>
                    <div class="form-group" style="padding-top:20px ">
                        <label class="sr-only" for="engName">英文名字</label>
                        <input type="text" class="form-control" id="engName" placeholder="英文名字" name="engName">
                    </div>
                    <div class="form-group" style="padding-top:20px ">
                        <button class="btn btn-default" id="addItemSubmit">添加</button>
                    </div>
                </form>
            </div>


            <!--            类目表-->
            <h1 align="center" style="position: relative; top: 22px">类目列表</h1>
            <div style="padding-top: 40px">

                <table id="itemtable" class="table table-hover table-bordered" style="width: 1000px"
                       align="center"></table>
            </div>
        </div>

    </div>
</div>


<script>
    $(function () {
        $("#addItemSubmit").click(function () {
            let itemName = $("#itemName").val();
            let engName = $("#engName").val();
            if ((itemName == null || itemName.trim() == "") || (engName == null || engName.trim() == "")) {
                alert("不能为空或全部是空格")
            } else {
                $.ajax({
                    url: 'http://localhost:8080/item/addItem',
                    type: 'POST',
                    data: {
                        name: itemName,
                        alias: engName
                    },
                    success: function (data) {
                        alert("添加成功");
                    }
                })
            }
        })

    })

</script>


<!-- jquery
    ============================================ -->
<!--<script src="js/vendor/jquery-1.12.4.min.js"></script>-->
<!-- bootstrap JS
    ============================================ -->
<script src="js/bootstrap.min.js"></script>
<!--<script src="js/bootstrap.min.js"></script>-->
<!-- wow JS
    ============================================ -->
<script src="js/wow.min.js"></script>
<!-- price-slider JS
    ============================================ -->
<script src="js/jquery-price-slider.js"></script>
<!-- meanmenu JS
    ============================================ -->
<script src="js/jquery.meanmenu.js"></script>
<!-- owl.carousel JS
    ============================================ -->
<script src="js/owl.carousel.min.js"></script>
<!-- sticky JS
    ============================================ -->
<script src="js/jquery.sticky.js"></script>
<!-- scrollUp JS
    ============================================ -->
<script src="js/jquery.scrollUp.min.js"></script>
<!-- counterup JS
    ============================================ -->
<script src="js/counterup/jquery.counterup.min.js"></script>
<script src="js/counterup/waypoints.min.js"></script>
<script src="js/counterup/counterup-active.js"></script>
<!-- mCustomScrollbar JS
    ============================================ -->
<script src="js/scrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
<script src="js/scrollbar/mCustomScrollbar-active.js"></script>
<!-- metisMenu JS
    ============================================ -->
<script src="js/metisMenu/metisMenu.min.js"></script>
<script src="js/metisMenu/metisMenu-active.js"></script>
<!-- morrisjs JS
    ============================================ -->
<script src="js/morrisjs/raphael-min.js"></script>
<script src="js/morrisjs/morris.js"></script>
<script src="js/morrisjs/home3-active.js"></script>
<!-- morrisjs JS
    ============================================ -->
<script src="js/sparkline/jquery.sparkline.min.js"></script>
<script src="js/sparkline/jquery.charts-sparkline.js"></script>
<script src="js/sparkline/sparkline-active.js"></script>
<!-- calendar JS
    ============================================ -->
<script src="js/calendar/moment.min.js"></script>
<script src="js/calendar/fullcalendar.min.js"></script>
<script src="js/calendar/fullcalendar-active.js"></script>
<!-- plugins JS
    ============================================ -->
<script src="js/plugins.js"></script>
<!-- main JS
    ============================================ -->
<script src="js/main.js"></script>
<!-- tawk chat JS
    ============================================ -->
<!--<script src="js/tawk-chat.js"></script>-->

</body>

</html>
<script src="js/my/logOut.js"></script>
<script src="js/my/headImgAndName.js"></script>